creating stored function in postgresql